<template>
	<view class="self-evaluation">
		<cu-custom isBack="true"></cu-custom>
		<header-title>
			<block slot="title">自我评论</block>
		</header-title>

		<my-textarea :valMax="valMax" v-model="val" heigth="600rpx"></my-textarea>

		<footer-btn @submit="submitHandle">
			<text slot="text">保存</text>
		</footer-btn>
	</view>
</template>

<script>
	import headerTitle from '../../components/header-title/header-title.vue';
	import footerBtn from '../../components/footer-btn/footer-btn.vue';
	import myTxtarea from '../../components/my-textarea/my-textarea.vue';

	export default {
		components: {
			headerTitle,
			footerBtn,
			myTxtarea
		},
		data() {
			return {
				valMax: 1000,
				val: '',
				pageType: 'add'
			};
		},
		onLoad(option) {
			let {
				pageType = 'add'
			} = option
			if (pageType == 'update') {
				let evaluate_about = this.$store.getters['update/getEvaluateInfoData']
				this.val = evaluate_about
			}
			this.pageType = pageType
		},
		methods: {
			submitHandle() {
				if (!this.$validate.isEmpty(this.val)) {
					this.$comm.errorToShow("自我评论不能为空")
					return false
				}
				if (this.pageType == 'update') {
					this.$comm.navigateBack(1, () => {
						uni.$emit('updateEvaluateInfo', this.val)
					})
				} else if (this.pageType == 'add') {
					this.$store.commit('add/setEvaluateInfoData', this.val)

					let resumeInfo = this.$store.getters['add/getResumeInfoData']
					//输入了所有的数据
					this.$api.addResume(resumeInfo).then(res => {
						if (res.code) {
							this.$comm.successToShow("添加简历成功", () => {
								this.$comm.reLaunch('/pages/index/index')
							})
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.self-evaluation {}
</style>
